package com.tarena.lbs.user.service.impl;

import com.tarena.lbs.user.dao.repository.UserTagsRepository;
import com.tarena.lbs.user.pojo.param.UserTagsParam;
import com.tarena.lbs.user.pojo.po.UserTagsPO;
import com.tarena.lbs.user.service.UserTagsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class UserTagsServiceImpl implements UserTagsService {
    @Autowired
    private UserTagsRepository userTagsRepository;
    @Override
    public void userTag(UserTagsParam param) {
        UserTagsPO userTagsPO=new UserTagsPO();
        userTagsPO.setUserId(param.getUserId());
        String[] items= param.getTagIds().trim().split(",");
        int[] tags=new int[items.length];
        for (int i = 0; i < items.length; i++) {
            tags[i]= Integer.parseInt(items[i]);
        }
        for (int i = 0; i < tags.length; i++) {
            userTagsPO.setTagId(tags[i]);
            userTagsRepository.userTag(userTagsPO);
        }

    }
}
